#include "time_wheel_handler.h"

namespace qio {
TimeWheelHandle::TimeWheelHandle(TimeWheel *wheel,
                                 const SharedTcpConn &weak)
    QIO_NOEXCEPT  // NOLINT
    : wheel_(wheel),
      weak_tcp_conn_(WeakTcpConn{weak}) {}

TimeWheelHandle::~TimeWheelHandle() QIO_NOEXCEPT {
  auto strong = weak_tcp_conn_.lock();
  if (strong) {
    strong->Close();
  }
}

TimeoutMs TimeWheelHandle::GetTimeoutMs() const QIO_NOEXCEPT {
  return wheel_->GetTimeoutMs();
}

void TimeWheelHandle::Reset() QIO_NOEXCEPT {
  // 追加到 TimeWheel 中
  wheel_->AddEntry(GetSharedHandle());
}

void TimeWheelHandle::Pause() QIO_NOEXCEPT {
  // 不需要做任何操作
}
}  // namespace qio